﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Recon.Portal.Business;
using Recon.Portal.DataObjects;

namespace Recon.Portal.WebUI
{
    public partial class ForgotPasswordPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label lblDateTime = ((Label)Master.FindControl("lblDateTime"));
            lblDateTime.Visible = false;
            Menu mnRecon = ((Menu)Master.FindControl("mnReconEngine"));
            mnRecon.Visible = false;
            //PasswordRecovery1.Focus();
        }
        protected void btnok_Click(object sender, EventArgs e)
        {
            btnClickPopup.Hide();
        }
        protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e)
        {
            UserEntity userEntity = new UserEntity();
            User user = userEntity.GetUserSpecificDetails(PasswordRecovery1.UserName, ((TextBox)PasswordRecovery1.Controls[0].FindControl("txtCustomerID")).Text);
            if (user != null)
            {
                user.IsForcedPasswordChange = true;
                userEntity.setForcePwdChange(user);// we can do in single function, where we need to check user available & change force flag

                e.Cancel = true;
                SignInLink.Text = "Sign In";
                SignInLink.Visible = true;
                SignInLink.NavigateUrl = "ReconSignIn.aspx";
                lblErrorMsg.Text = "* Details has been sent.";
                lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text = "Password has been reset successfully and sent to your registered email id.";
                btnClickPopup.Show();
            }
            else
            {
                e.Cancel = true;
                SignInLink.Visible = false;
                lblErrorMsg.Text = "* Invalid user " + PasswordRecovery1.UserName;
                lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                btnClickPopup.Show();
            }
        }
    }
}